import router from "./index";

// 路由拦截
router.beforeEach((to,from,next)=>{
    // matched 包含父路由和当前路由
    let isLogin=to.matched.some(item=>item.meta.isLogin);
    if(isLogin){  //需要登录
        console.log('token:',localStorage.getItem('token'))
        let token=localStorage.getItem('token');  //取token
        if(token){
             next();
        }else{
             next('/login');
        }     
    }else{
        next();  //放行
    }

})